<template>
  <div class="app-container">
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
          v-hasPermi="['shop:manage:export']">导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="manageList">
      <el-table-column label="排名" align="center" type="index" />
      <el-table-column label="商户名称" align="center" prop="name" />
      <el-table-column label="门店地址" align="center" prop="address" />
      <el-table-column label="审核状态" align="center" prop="audit">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.che_shop_audit" :value="scope.row.audit" />
        </template>
      </el-table-column>
      <el-table-column label="负责人" align="center" prop="perName" />
      <el-table-column label="平均星级" align="center" prop="star">
        <template slot-scope="scope">
        <el-rate :value="scope.row.star" :disabled='true'></el-rate>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

  </div>
</template>

<script>
  import {
    listRank,
  } from "@/api/shop/manage";

  export default {
    name: "Manage",
    dicts: ['che_shop_audit'],
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 商户管理表格数据
        manageList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          name: null,
          address: null,
        },
        // 表单参数
        form: {},
      };
    },
    created() {
      this.getList();
    },
    methods: {
      /** 查询商户管理列表 */
      getList() {
        this.loading = true;
        listRank().then(response => {
          this.manageList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          id: null,
          name: null,
          number: null,
          area: null,
          address: null,
          intro: null,
          audit: null,
          creatTime: null,
          licence: null,
          cardFront: null,
          cardBack: null,
          money: null,
          accIncome: null,
          accOut: null,
          perName: null,
          perPhone: null,
          perPasword: null,
          perCardid: null,
          deleted: null,
          storeName: null,
          week: null,
          startTime: null,
          endTime: null,
          longitude: null,
          latitude: null,
          star: null,
          sales: null
        };
        this.resetForm("form");
      },
      /** 导出按钮操作 */
      handleExport() {
        this.download('shop/manage/export', {
          ...this.queryParams
        }, `manage_${new Date().getTime()}.xlsx`)
      }
    }
  };
</script>

<style>
  .el-rate {
    display: inline-block;
    vertical-align: text-top;
  }
</style>
